import { HttpStatus, MidwayHttpError } from '@midwayjs/core';

const codeMsgs = {
  '200': '请求成功',
};

/**
 * 自定义的响应错误，该错误将会返回统一的错误消息体
 */
export class ResponseError extends MidwayHttpError {
  public msgcode: number;

  constructor(msgcode: number, msg?: string) {
    super(msg || codeMsgs[`${msgcode}`], HttpStatus.BAD_REQUEST);
    this.msgcode = msgcode;
  }
}
